/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controllers;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

/**
 *
 * @author ayle
 */
public class CUsers implements IUsers {

    public MUsers getMUsers() {
        return MUsers.getMUsers();
    }

    @Override
    public void newUser(String nick, String email, String name, String surname, String pass) throws Exception {
        try {
            MUsers manager = getMUsers();
            manager.newUser(nick.toLowerCase(), email.toLowerCase(), name, surname, pass);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }
    }

    @Override
    public boolean existUser(String nick, String email) {
        MUsers manager = getMUsers();
        return manager.existUser(nick, email);
    }

    @Override
    public void editUser(String nick, String newnick, String email, String name, String surname, String pass) throws Exception {
        try {
            MUsers manager = getMUsers();
            manager.editUser(nick.toLowerCase(), newnick.toLowerCase(), email.toLowerCase(), name, surname, pass);
        } catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }
    }

//    @Override
//    public DataUser showUser(String nick) {
//        MUsers manager = getMUsers();
//        return manager.showUser(nick);
//    }
    @Override
    public List listUsers() {
        MUsers manager = getMUsers();
        return manager.listUsers();
    }

    @Override
    public boolean validatePass(String nick, String pass) {
        try {
            MUsers manager = getMUsers();
            return manager.validatePass(nick, pass);
        } catch (FileNotFoundException ex) {
//            Logger.getLogger(CPerfil.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        } catch (IOException ex) {
//            Logger.getLogger(CPerfil.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
//    @Override
//    public void encryptAndStorePass(String nick, String pass) throws IOException {
//        try {
//            MUsers manager = getMUsers();
//            manager.encryptAndStorePass(nick, pass);
//        } catch (IOException ex) {
//            throw new IOException(ex.getMessage());
//        }
//    }
}
